package com.duyj.uitl;

import com.fasterxml.uuid.EthernetAddress;
import com.fasterxml.uuid.Generators;

import java.io.IOException;
import java.util.UUID;

/**
 * ID生成器
 */
public class IDGenerator {

    /**
     * 私有构造函数，防止实例化
     */
    private IDGenerator() {
    }

    /**
     * 获得32位的UUID
     * @return
     * @throws IOException
     */
    public static String newID() {
        EthernetAddress nic = EthernetAddress.constructMulticastAddress();
        UUID uuid = Generators.timeBasedGenerator(nic).generate();
        return uuid.toString().replace("-", "");
    }
}
